package day0227;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class StringMethods {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String str = "kaifamiao";

//        System.out.println(str.charAt(0)); // k

        System.out.println(str.codePointAt(0)); // 97

        System.out.println("a".compareTo("A")); // 32
        System.out.println("a".compareToIgnoreCase("A")); // 0

        System.out.println("abcd".concat("efg")); // abcdefg
        System.out.println("abcd" + "efg"); // abcdefg


        String s = "开发喵";

        // 默认编码 UTF-8 == Charset.defaultCharset();
        byte[] bytes = s.getBytes();

        System.out.println(Arrays.toString(bytes));

        String s1 = new String(bytes, "gbk");
        System.out.println(s1); // 乱码


        String s2 = ".a1.b2.c3.";

        System.out.println(s2);

        String[] split = s2.split("\\.");
        System.out.println(Arrays.toString(split));

        System.out.println(Arrays.toString("abcdefg".split(""))); // [a, b, c, d, e, f, g]


        boolean contains = s.contains("");
        System.out.println(contains);

    }
}
